package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.ProjectManagementDao;
import cn.topevery.garden.entity.po.ProjectManagement;
import cn.topevery.garden.entity.query.ProjectManagementQuery;
import cn.topevery.garden.entity.vo.ProjectManagementVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 项目管理信息表
 *
 * @author code-generate
 * @date 2022-02-15
 */
@Service
public class ProjectManagementLogic extends BaseLogic<ProjectManagement> {
    @Autowired
    ProjectManagementDao projectManagementDao;

    @Override
    public BaseEntityDao<ProjectManagement, Integer> getDao() {
        return projectManagementDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<ProjectManagementVO> listPage(ProjectManagementQuery query) {
        return projectManagementDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        projectManagementDao.deleteBatchById(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param projectManagement 实体
     */
    public void saveOrUpdate(String userId, ProjectManagement projectManagement){
        projectManagementDao.saveOrUpdate(userId,projectManagement);
    }

    /**
         * 根据自定义列值来获取对象
         */
    public ProjectManagement getEntityByColumn(String key, String value) {
        return projectManagementDao.getEntityByColumn(key, value);
    }

    public List<Map<String, Object>> getProjectNameList() {
        return projectManagementDao.getProjectNameList();
    }

    public void save(String userId, ProjectManagement projectManagement) {
        projectManagementDao.saveOrUpdate(userId, projectManagement);
//        if (projectManagement.getLng() != null && projectManagement.getLat() != null) {
//            projectManagementDao.updateMapRange(projectManagement.getId(), projectManagement.getLat(), projectManagement.getLng());
//        }
    }
}
